<template>
	<div class="paytel">
		<div class="paytitle">
			<p>确认付款</p>
			<h3>￥{{ordermoney}}</h3>
			<p>可用余额：￥{{yuemoney}}</p>
		</div>
		<ul class="login-from payfrom">
			<li><span><img src="../../img-login/icon_phone_dis@3x.png"/></span><input type="number" name="" id="" value="" placeholder="请输入手机号码" v-model="tel" readOnly="true"/></li>
			<li class="login-yzm payyzm"><span><img src="../../img-login/icon_check_dis@3x.png"/></span><span><img src="../../img-login/icon_check_sel@3x.png"/></span><input type="number" name="" id="" value="" placeholder="请输入验证码" v-model="yzm"/><span @click="hqyzm()" v-if="yzmshow">获取验证码</span><span v-else class="cxfs" v-html="djsyzm"></span></li>
		</ul>
		<div class="paybtn" @click="telquerenpay()">确认支付</div>
	</div>
</template>

<script>
	
	var furl = 'http://www.ntyouxuan.com/';
	export default{
		name:'paytel',
		data(){
			return{
				telimgshow:false,
				tel:'',
				yzm:'',
				yzmshow:true,
				yzmimgshow:false,
				djsyzm:'60秒后<br />重新发送',
				user:0,
				orderid:0,
				ordermoney:'0.00',
				yuemoney:'0.00'
			}
		},
		created:function(){
			this.user=localStorage.getItem('nt_user');
			this.orderid=this.$route.query.ordertoken;
			var self=this;
			$.ajax({
				type:'post',
				url:furl+'index.php?app=ajax_epay&act=payment_show',
				data:{'token':self.user,'order_id':self.orderid},
				dataType:'json',
				success:function(res){
					self.tel=res.retval.phone_mob;
					self.ordermoney=res.retval.order_info.order_amount;
					self.yuemoney=res.retval.money.money;
					
				}
				
			})
		},
		methods:{
			telquerenpay:function(){
				var self=this;
				$.ajax({
					type:"post",
					url:furl+"index.php?app=ajax_epay&act=payment_post",
					data:{'token':self.user,'phone_mob':self.tel,'post_money':self.ordermoney,'order_id':self.orderid,'zf_pass':self.yzm},
					dataType:'json',
					success:function(res){
						if(res.done){
							self.$router.push({path:'/payrequet/paysucs',query:{ordertoken:self.orderid}});
						}
						
					}
				});
				
			},
			hqyzm:function(){
				var self=this;
				if(this.tel&&this.tel.length==11){
					this.yzmshow=false;
					self.djsyzm='60秒后<br />重新发送';
					for(var i=60;i>0;i--){
						(function(i){
							var a=i;
							var b=60;
							setTimeout(function(){
								self.djsyzm=b-a+'秒后<br />重新发送';
								if(a==60){
									self.yzmshow=true;
								}
							},i*1000);
						})(i);
					};
					$.ajax({
						type:"post",
						url:furl+"index.php?app=ajax_epay&act=withdraw_tx",
						data:{"phone":self.tel},
						dataType:"json",
						success:function(res){
							console.log(res);
						}
					});
				}
			}
		}
		
	}
</script>

<style>
</style>